package com.cennavi.minenavidemo.widget;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

import com.cennavi.minenavidemo.R;

/**
 * 单选按钮控件
 */
public class MyCheckButton extends androidx.appcompat.widget.AppCompatImageView {
	private boolean mIsChecked;

	public MyCheckButton(Context context) {
		super(context);
		init();
	}

	public MyCheckButton(Context context, @Nullable AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public MyCheckButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init();
	}

	private void init() {
		setImageResource(R.drawable.uncheck);
		mIsChecked = false;
	}

	public void enableChecked(boolean isChecked) {
		mIsChecked = isChecked;
		if (mIsChecked) {
			setImageResource(R.drawable.check);
		} else {
			setImageResource(R.drawable.uncheck);
		}
	}

	public boolean isEnableChecked() {
		return mIsChecked;
	}
}
